SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for tms_customer_background_check
-- ----------------------------
DROP TABLE IF EXISTS `tms_customer_background`;
CREATE TABLE `tms_customer_background` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `company_id` bigint NOT NULL COMMENT '公司ID',
  `company_name` varchar(255) NOT NULL COMMENT '公司名称',
  `check_date` date DEFAULT NULL COMMENT '背调日期',
  `checker` varchar(100) DEFAULT NULL COMMENT '背调人',
  `legal_person` varchar(100) DEFAULT NULL COMMENT '法人代表',
  `registered_capital` decimal(18,2) DEFAULT NULL COMMENT '注册资本（万元）',
  `establishment_date` date DEFAULT NULL COMMENT '成立日期',
  `business_scope` text COMMENT '经营范围',
  `credit_rating` varchar(50) DEFAULT NULL COMMENT '信用等级（字典：credit_rating）',
  `litigation_records` text COMMENT '诉讼记录',
  `violation_records` text COMMENT '违规记录',
  `business_reputation` varchar(500) DEFAULT NULL COMMENT '商业信誉',
  `financial_status` varchar(500) DEFAULT NULL COMMENT '财务状况',
  `cooperation_history` text COMMENT '合作历史',
  `risk_assessment` varchar(50) DEFAULT NULL COMMENT '风险评估（字典：risk_level）',
  `check_result` varchar(50) DEFAULT NULL COMMENT '背调结果（字典：check_result）',
  `check_conclusion` text COMMENT '背调结论',
  `attachments` text COMMENT '附件（JSON数组）',
  `remark` text COMMENT '备注',
  `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '更新者',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `deleted` bigint NOT NULL DEFAULT 0 COMMENT '是否删除',
  `tenant_id` bigint NOT NULL DEFAULT '0' COMMENT '租户编号',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_company_id` (`company_id`) USING BTREE,
  KEY `idx_check_date` (`check_date`) USING BTREE,
  KEY `idx_check_result` (`check_result`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='客户背调表';

-- ----------------------------
-- Records
-- ----------------------------
BEGIN;
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;
